// pages/salesmans/salesmanAccount/salesmanAccount.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page: 1,
    page_count: 1,
    record_data: [],
    empty: false,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.salesmanList();
  },



  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var that = this;
    var page = that.data.page + 1;
    if (page > that.data.page_count) {
      that.setData({
        noMore: true
      })
      return false;
    }
    that.setData({
      page: page
    })
    that.salesmanList();
  },
  salesmanList() {
    var that = this;
    app.ajax({
      url: 'Partner/Salesman/salesmanList',
      method: "POST",
      data: {
        page: that.data.page,
        row: 5,
      },
      success: function (res) {
        var flag = res.data;
        if (flag.code > 0) {
          var record = that.data.record_data.concat(flag.data.data)
          that.setData({
            record_data: record,
            page_count: flag.data.page.page_count,
            empty: flag.data.page.page_count == 0 ? true : false
          });
        }
      }
    })
  },
})